package com.tom.angel.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tom.angel.dao.UserDaoI;
import com.tom.angel.model.User;
import com.tom.angel.service.UserServiceI;

@Service("userService")
public class UserServiceImpl implements UserServiceI {
	
	private UserDaoI userDao;
	
	
	public UserDaoI getUserDaoIntegerface() {
		return userDao;
	}


	@Autowired
	public void setUserDaoIntegerface(UserDaoI userDaoIntegerface) {
		this.userDao = userDaoIntegerface;
	}


	public User getUser(String userName,String passWord){
		
		String hql = "FROM User o WHERE o.userName=:userName AND o.userPass=:passWord" ;
		
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("userName", userName);
		map.put("passWord", passWord);
		
		List<User> users = userDao.find(hql,map);
		
		User user = null;
		
		if(users.size()>0){
			user = users.get(0);
		}
		return user;
	}
}
